#include "ShapeManagerWidget.h"
#include <QPainter>

ShapeManagerWidget::ShapeManagerWidget(QWidget* parent): QListView(parent)
{
	SetupWidget();
}

ShapeManagerWidget::~ShapeManagerWidget()
{
}

void ShapeManagerWidget::SetupWidget()
{
	model = new ShapeModel(this);
	//layout = new QVBoxLayout(this);
	//listView = new QListView(this);
	//listView->setViewMode(QListView::IconMode);
	//listView->setIconSize(QSize(60, 60));
	//listView->setGridSize(QSize(140, 80));
	//listView->setMovement(QListView::Snap);
	//listView->setSpacing(10);
	//listView->setResizeMode(QListView::Adjust);
	
	//layout->addWidget(listView);

	//listView->setModel(model);
	setViewMode(QListView::IconMode);
	setIconSize(QSize(60, 60));
	setGridSize(QSize(140, 80));
	setMovement(QListView::Snap);
	//setSpacing(10);
	//setResizeMode(QListView::Adjust);
	setModel(model);

	QPixmap p("cube.png");

	model->AddShape(p);
	model->AddShape(p);
	model->AddShape(p);
	model->AddShape(p);
	//model->AddShape(
}

QSize ShapeManagerWidget::sizeHint() const
{
	return QSize(400, 200);
}

QSize ShapeManagerWidget::minimumSizeHint() const
{
	return QSize(100, 100);
}

void ShapeManagerWidget::paintEvent(QPaintEvent *e)
{
	
	//QPainter painter(this);

    //painter.setPen(palette().dark().color());
	//painter.setPen(Qt::blue);
	//painter.setBrush(QBrush(Qt::blue));
    //painter.drawRect(QRect(0, 0, width() - 1, height() - 1));
	

	QListView::paintEvent(e);
}

// Allocate a new shape
/*
::Shape* ShapeManagerWidget::NewShape(const ::Shape& shape)
{
	return new ::Shape(shape);
}
*/
